home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / impOpen.z / impOpen
Encoding:
Text File  |  2002-10-03  |  21.9 KB  |  397 lines

  1.  
  2.  
  3.  
  4. iiiimmmmppppOOOOppppeeeennnn((((3333))))                       IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo                        iiiimmmmppppOOOOppppeeeennnn((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      impOpen, impOpenFd, impOpenBuf, impOpenExt, impOpenFdExt, impOpenBufExt,
  10.      impClose, impCloseFd - open/close SGI Image Format files
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<iiiimmmmpppp....hhhh>>>>
  14.  
  15.      IIIIMMMMPPPPIIIImmmmaaaaggggeeee**** iiiimmmmppppOOOOppppeeeennnn((((ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ffffnnnnaaaammmmeeee,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****mmmmooooddddeeee,,,, ............))));;;;
  16.  
  17.      IIIIMMMMPPPPIIIImmmmaaaaggggeeee**** iiiimmmmppppOOOOppppeeeennnnFFFFdddd((((iiiinnnntttt ffffdddd,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****mmmmooooddddeeee,,,, ............))));;;;
  18.  
  19.      IIIIMMMMPPPPIIIImmmmaaaaggggeeee**** iiiimmmmppppOOOOppppeeeennnnBBBBuuuuffff((((vvvvooooiiiidddd ****bbbbuuuuffff,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****mmmmooooddddeeee,,,, ............))));;;;
  20.  
  21.      IIIIMMMMPPPPIIIImmmmaaaaggggeeee**** iiiimmmmppppOOOOppppeeeennnnEEEExxxxtttt((((ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ffffnnnnaaaammmmeeee,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****mmmmooooddddeeee,,,,
  22.                           ooooffffffff____tttt ooooffffffffsssseeeetttt,,,, IIIIMMMMPPPPCCCCaaaacccchhhheeeeMMMMooooddddeeee ccccaaaacccchhhheeee,,,, ............))));;;;
  23.  
  24.      IIIIMMMMPPPPIIIImmmmaaaaggggeeee**** iiiimmmmppppOOOOppppeeeennnnFFFFddddEEEExxxxtttt((((iiiinnnntttt ffffdddd,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****mmmmooooddddeeee,,,,
  25.                             ooooffffffff____tttt ooooffffffffsssseeeetttt,,,, IIIIMMMMPPPPCCCCaaaacccchhhheeeeMMMMooooddddeeee ccccaaaacccchhhheeee,,,, ............))));;;;
  26.  
  27.      IIIIMMMMPPPPIIIImmmmaaaaggggeeee**** iiiimmmmppppOOOOppppeeeennnnBBBBuuuuffffEEEExxxxtttt((((vvvvooooiiiidddd ****bbbbuuuuffff,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****mmmmooooddddeeee,,,,
  28.                              ooooffffffff____tttt ooooffffffffsssseeeetttt,,,, ............))));;;;
  29.  
  30.      iiiinnnntttt iiiimmmmppppCCCClllloooosssseeee((((IIIIMMMMPPPPIIIImmmmaaaaggggeeee ****iiiimmmmaaaaggggeeee))));;;;
  31.  
  32.      iiiinnnntttt iiiimmmmppppCCCClllloooosssseeeeFFFFdddd((((IIIIMMMMPPPPIIIImmmmaaaaggggeeee ****iiiimmmmaaaaggggeeee,,,, iiiinnnntttt ****ffffddddpppp))));;;;
  33.  
  34.      In write mode iiiimmmmppppOOOOppppeeeennnn, iiiimmmmppppOOOOppppeeeennnnFFFFdddd, iiiimmmmppppOOOOppppeeeennnnEEEExxxxtttt and iiiimmmmppppOOOOppppeeeennnnFFFFddddEEEExxxxtttt require
  35.      that these additional parameters be specified:
  36.  
  37.      uuuuiiiinnnntttt____tttt rrrraaaasssstttteeeerrrrTTTTyyyyppppeeee,,,, uuuuiiiinnnntttt____tttt ddddiiiimmmmeeeennnnssssiiiioooonnnn,,,, uuuuiiiinnnntttt____tttt xxxxSSSSiiiizzzzeeee,,,, uuuuiiiinnnntttt____tttt yyyySSSSiiiizzzzeeee,,,, uuuuiiiinnnntttt____tttt
  38.      nnnnuuuummmmCCCChhhhaaaannnnnnnneeeellllssss,,,, uuuuiiiinnnntttt____tttt iiiimmmmaaaaggggeeeeTTTTyyyyppppeeee,,,, cccchhhhaaaarrrr ****nnnnaaaammmmeeee
  39.  
  40.      where uuuuiiiinnnntttt____tttt stands for uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttt.
  41.  
  42. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  43.      The _l_i_b_i_m_p library provides a number of different functions to open an
  44.      SGI Image Format file. The _i_m_p_O_p_e_n, _i_m_p_O_p_e_n_F_d, _i_m_p_O_p_e_n_E_x_t and
  45.      _i_m_p_O_p_e_n_F_d_E_x_t functions each open an SGI Image Format file for reading or
  46.      writing.
  47.  
  48.      _i_m_p_O_p_e_n opens the image file specified by _f_n_a_m_e. If _m_o_d_e is """"rrrr"""", the file
  49.      is opened for reading. If _m_o_d_e is """"wwww"""" the file is opened for writing and
  50.      created if it does not exist or truncated to zero length if it does
  51.      exist.
  52.  
  53.      IIIIMMMMPPPPIIIImmmmaaaaggggeeee**** iiiimmmmppppOOOOppppeeeennnn((((ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ffffnnnnaaaammmmeeee,,,, """"rrrr""""))));;;; IIIIMMMMPPPPIIIImmmmaaaaggggeeee**** iiiimmmmppppOOOOppppeeeennnn((((ccccoooonnnnsssstttt cccchhhhaaaarrrr
  54.      ****ffffnnnnaaaammmmeeee,,,, """"wwww"""",,,, uuuuiiiinnnntttt____tttt                         rrrraaaasssstttteeeerrrrTTTTyyyyppppeeee,,,, uuuuiiiinnnntttt____tttt ddddiiiimmmmeeeennnnssssiiiioooonnnn,,,,
  55.      uuuuiiiinnnntttt____tttt xxxxSSSSiiiizzzzeeee,,,, uuuuiiiinnnntttt____tttt yyyySSSSiiiizzzzeeee,,,, uuuuiiiinnnntttt____tttt                         nnnnuuuummmmCCCChhhhaaaannnnnnnneeeellllssss,,,,
  56.      uuuuiiiinnnntttt____tttt iiiimmmmaaaaggggeeeeTTTTyyyyppppeeee,,,, cccchhhhaaaarrrr ****nnnnaaaammmmeeee))));;;;
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. iiiimmmmppppOOOOppppeeeennnn((((3333))))                       IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo                        iiiimmmmppppOOOOppppeeeennnn((((3333))))
  71.  
  72.  
  73.  
  74.      Excess arguments to _i_m_p_O_p_e_n over the above are ignored.
  75.  
  76.      _i_m_p_O_p_e_n_F_d opens the image file pointed to by the file descriptor _f_d. The
  77.      descriptor's permissions must permit the operations specified by _m_o_d_e.
  78.      That is, if _m_o_d_e is """"wwww"""", the descriptor must have write permission. In
  79.      addition, it must be possible to seek on the specified descriptor.
  80.  
  81.      At this time read/write mode is not supported for SGI Image files. Upon
  82.      successful execution both functions return a pointer to an SGI Image file
  83.      structure.
  84.  
  85.      If _i_m_p_O_p_e_n or _i_m_p_O_p_e_n_F_d open an image file for writing, a number of
  86.      additional parameters must be specified.
  87.  
  88.      _r_a_s_t_e_r_T_y_p_e     Specifies both the raster encoding method and the number
  89.                     of bytes per pixel per channel. SGI Image Format files can
  90.                     be written either uncompressed or with run length encoding
  91.                     compression and with one or two bytes per pixel per
  92.                     channel. Refer to _i_m_p._h for the supported raster types.
  93.  
  94.      _d_i_m_e_n_s_i_o_n      Specifies the number of dimensions in the image. A
  95.                     colormap file will have dimension one. A black and white
  96.                     image will have dimension two and an RGB image will have
  97.                     dimension three.
  98.  
  99.      _x_S_i_z_e, _y_S_i_z_e   Specifies the image size in pixels.
  100.  
  101.      _n_u_m_C_h_a_n_n_e_l_s    Specifies the number of image color channels. A black and
  102.                     white image has one channel while an RGB image has three
  103.                     channels.
  104.  
  105.      _i_m_a_g_e_T_y_p_e      Specifies how the image data is to be interpreted. Image
  106.                     data is either actual color values (normal), screen
  107.                     colormap indices (screen) or a colormap (colormap). Refer
  108.                     to _i_m_p._h for the supported image types.
  109.  
  110.      _n_a_m_e           Specifies a descriptive string for the image. Strings
  111.                     longer than IIIIMMMMPPPP____NNNNAAAAMMMMEEEE____MMMMAAAAXXXX characters will be truncated.
  112.                     Refer to _i_m_p._h for the value of IIIIMMMMPPPP____NNNNAAAAMMMMEEEE____MMMMAAAAXXXX. If this
  113.                     parameter is specified as NNNNUUUULLLLLLLL, the string "no name" will
  114.                     be written into the file. Use the empty string "" to write
  115.                     an empty name string into the image.
  116.  
  117.      The _i_m_p_O_p_e_n_E_x_t and _i_m_p_O_p_e_n_F_d_E_x_t functions also open an image file but in
  118.      addition allow an offset and image cache mode to be specified.  The
  119.      offset is the number of bytes into the file where the image is to be read
  120.      or written. The cache mode is used only during image reading and
  121.      specifies how the image data is to be accessed for subsequent reads. The
  122.      value of the cache mode is ignored when in writing mode (the mode is
  123.      implicitly IIIIMMMMPPPPNNNNooooCCCCaaaacccchhhheeee). The cache mode may be one of:
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. iiiimmmmppppOOOOppppeeeennnn((((3333))))                       IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo                        iiiimmmmppppOOOOppppeeeennnn((((3333))))
  137.  
  138.  
  139.  
  140.      IIIIMMMMPPPPNNNNooooCCCCaaaacccchhhheeee
  141.                Do not cache the image data. All subsequent image reads will be
  142.                done from the disk file or descriptor.
  143.  
  144.      IIIIMMMMPPPPHHHHeeeeaaaappppCCCCaaaacccchhhheeee
  145.                Cache the image data in storage allocated from the heap. All
  146.                subsequent image reads will be done from the data stored in the
  147.                heap cache.
  148.  
  149.      IIIIMMMMPPPPMMMMaaaappppCCCCaaaacccchhhheeee
  150.                Memory map the image file. All subsequent image reads will use
  151.                the memory mapping facility to reference the image data.
  152.  
  153.      The _i_m_p_O_p_e_n_B_u_f and _i_m_p_O_p_e_n_B_u_f_E_x_t functions allow reading an SGI Image
  154.      that is already in memory. Writing of the image is not currently
  155.      supported by these two functions. The buffer specified in the call to
  156.      _i_m_p_O_p_e_n_B_u_f and _i_m_p_O_p_e_n_B_u_f_E_x_t must not be deallocated until _i_m_p_C_l_o_s_e has
  157.      been called.
  158.  
  159.      _i_m_p_C_l_o_s_e closes an SGI Image Format file previously opened by _i_m_p_O_p_e_n or
  160.      _i_m_p_O_p_e_n_F_d. Among other tasks, _i_m_p_C_l_o_s_e closes the file descriptor
  161.      associates with image file if appropriate. If the image was opened using
  162.      _i_m_p_O_p_e_n_F_d or _i_m_p_O_p_e_n_F_d_E_x_t, the file descriptor specified in that function
  163.      call will be closed by _i_m_p_C_l_o_s_e.  _i_m_p_C_l_o_s_e_F_d performs the same function
  164.      as _i_m_p_C_l_o_s_e but it leaves open the file descriptor associated with the
  165.      image and returns it in the parameter _f_d_p. It then becomes the
  166.      responsibility of the caller to close the file descriptor when it is no
  167.      longer needed.  It is essential that either _i_m_p_C_l_o_s_e or _i_m_p_C_l_o_s_e_F_d be
  168.      called at the completion of writing an SGI Image file so that all
  169.      buffered data can be written and the image header can be updated. When an
  170.      image has been opened using _i_m_p_O_p_e_n_B_u_f or _i_m_p_O_p_e_n_B_u_f_E_x_t either close
  171.      function may be used.  If _i_m_p_C_l_o_s_e_F_d is used, -1 is returned as the file
  172.      descriptor.
  173.  
  174.      The _I_M_P_I_m_a_g_e structure contains public and private information about an
  175.      SGI Image file. This structure is identical both in size and field naming
  176.      to the _I_M_A_G_E structure defined in the header file _i_m_a_g_e._h included by
  177.      application that use the _l_i_b_i_m_a_g_e library.  While it has been common
  178.      practice to directly modify the public fields of the image structure,
  179.      this is not recommended. Macros are defined in _i_m_p._h for manipulating the
  180.      structure fields. It is strongly recommended that these macros be used to
  181.      set and get values from the image structure. The _I_M_P_I_m_a_g_e structure is
  182.      defined as follows.
  183.  
  184.           typedef struct _impImage {
  185.               /******* Public image header information (archived) */
  186.               ushort_t   imagic;         /* SGI Image file magic number */
  187.               ushort_t   type;           /* Raster type (e.g. verbatim, rle) */
  188.               ushort_t   dim;            /* Image dimension */
  189.               ushort_t   xsize;          /* X size (pixels) */
  190.               ushort_t   ysize;          /* Y size (pixels) */
  191.               ushort_t   zsize;          /* Number of channels (e.g. rgb = 3) */
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. iiiimmmmppppOOOOppppeeeennnn((((3333))))                       IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo                        iiiimmmmppppOOOOppppeeeennnn((((3333))))
  203.  
  204.  
  205.  
  206.               __int32_t  min;            /* Minimum intensity in image */
  207.               __int32_t  max;            /* Maximum intensity in image */
  208.               __uint32_t wastebytes;     /* Padding */
  209.               char       name[IMP_NAME_MAX+1];   /* Image name */
  210.               __uint32_t colormap;       /* Image type (e.g. colormap, normal) */
  211.               /******* Private image header information (core use only) */
  212.               __int32_t  file;
  213.               ushort_t   flags;
  214.               short      dorev;
  215.               short      x;
  216.               short      y;
  217.               short      z;
  218.               short      cnt;
  219.               short      *ptr;
  220.               short      *base;
  221.               short      *tmpbuf;
  222.               __uint32_t offset;
  223.               __uint32_t rleend;
  224.               __uint32_t *rowstart;
  225.               __int32_t  *rowsize;
  226.               off_t      start;
  227.               IMPCacheMode cache;
  228.               void*      cachebuf;
  229.               __uint32_t cachesize;
  230.               off_t      cacheoffset;
  231.           } IMPImage;
  232.  
  233.  
  234.      where _u_s_h_o_r_t__t is _u_n_s_i_g_n_e_d _s_h_o_r_t, ___i_n_t_3_2__t is a 32-bit integer and
  235.      ___u_i_n_t_3_2__t is a 32-bit unsigned integer.
  236.  
  237.      _m_a_g_i_c               Magic number identifying this file as an SGI Image
  238.                          Format file.
  239.  
  240.      _t_y_p_e                Bitwise OR combined code indicating the raster
  241.                          encoding method and the number of bytes per pixel per
  242.                          channel. Currently, SGI Image files support either a
  243.                          verbatim, uncompressed, raster encoding or a run
  244.                          length, compressed, encoding. Both of these encodings
  245.                          are available at one or two bytes per pixel per
  246.                          channel. The header file _i_m_p._h defines codes for all
  247.                          supported combinations of encoding methods and pixel
  248.                          widths.
  249.  
  250.      _d_i_m                 Number of dimensions to the image. A colormap file
  251.                          has dimension one (i.e. length). A black and white
  252.                          image has dimension two (i.e. height and width) and
  253.                          an RGB image has dimension three (i.e. height, width
  254.                          and depth).
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. iiiimmmmppppOOOOppppeeeennnn((((3333))))                       IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo                        iiiimmmmppppOOOOppppeeeennnn((((3333))))
  269.  
  270.  
  271.  
  272.      _x_s_i_z_e, _y_s_i_z_e        Image size in pixels.
  273.  
  274.      _z_s_i_z_e               Number of color channels or depth. A black and white
  275.                          image has one channel while an RGB image has three
  276.                          channels.
  277.  
  278.      _m_i_n, _m_a_x            The minimum and maximum intensity values in the
  279.                          image. These values are the minimum and maximum for
  280.                          all channels combined.
  281.  
  282.      _n_a_m_e                A descriptive name string for the image.
  283.  
  284.      _c_o_l_o_r_m_a_p            The image type. Refer to _i_m_p._h for the supported
  285.                          image type codes.  The field is named _c_o_l_o_r_m_a_p for
  286.                          compatibility with the _I_M_A_G_E structure used by the
  287.                          _l_i_b_i_m_a_g_e library.
  288.  
  289. RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
  290.      All image open function return a pointer to an image structure if
  291.      execution was successful. NNNNUUUULLLLLLLL is returned and _I_M_P_e_r_r_n_o is set if an
  292.      execution error has occurred.
  293.  
  294.      _i_m_p_C_l_o_s_e and _i_m_p_C_l_o_s_e_F_d return 0 if execution was successful. -1 is
  295.      returned and _I_M_P_e_r_r_n_o is set if an execution error has occurred.
  296.  
  297. EEEEXXXXEEEECCCCUUUUTTTTIIIIOOOONNNN EEEERRRRRRRROOOORRRR CCCCOOOODDDDEEEESSSS
  298.      In addition to the system error codes defined in _e_r_r_n_o._h, the following
  299.      _l_i_b_i_m_p specific error codes may be returned.
  300.  
  301.      All image open functions will fail under the following circumstances.
  302.  
  303.      IMP_ERR_READWRITE        Read/write mode is not supported.
  304.  
  305.      IMP_ERR_MEMALLOC         Dynamic memory allocation failed. This indicates
  306.                               an out-of-memory condition.
  307.  
  308.      IMP_ERR_BADMAGIC         Bad magic number in image file header. The file
  309.                               may not be and SGI Image Format file.
  310.  
  311.      IMP_ERR_BADRASTER        Unrecognized raster encoding method. Refer to
  312.                               _i_m_p._h for supported raster encodings.
  313.  
  314.      IMP_ERR_BADIMAGE         Unrecognized image type. Refer to _i_m_p._h for
  315.                               supported image types.
  316.  
  317.      In addition, _i_m_p_O_p_e_n_F_d and _i_m_p_O_p_e_n_F_d_E_x_t will fail under the following
  318.      circumstances.
  319.  
  320.      IMP_ERR_BADFD            The specified file descriptor is invalid.
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. iiiimmmmppppOOOOppppeeeennnn((((3333))))                       IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo                        iiiimmmmppppOOOOppppeeeennnn((((3333))))
  335.  
  336.  
  337.  
  338.      IMP_ERR_SEEK             A seek cannot be performed on the specified file
  339.                               descriptor.
  340.  
  341.      _i_m_p_O_p_e_n_B_u_f and _i_m_p_O_p_e_n_B_u_f_E_x_t may also return the following error code.
  342.  
  343.      IMP_ERR_NOWRITE          Writing mode not allowed by the function.
  344.  
  345.      _i_m_p_C_l_o_s_e and _i_m_p_C_l_o_s_e_F_d will fail under the following circumstances.
  346.  
  347.      IMP_ERR_WRITEFLAG        Attempt to write to an image file not opened for
  348.                               writing.
  349.  
  350.      IMP_ERR_BADBPP           Unsupported bytes per pixel value. Refer to
  351.                               _i_m_p._h for supported BPP values.
  352.  
  353.      IMP_ERR_BADIMAGE         Unrecognized image type. Refer to _i_m_p._h for
  354.                               supported image types.
  355.  
  356. NNNNOOOOTTTTEEEE
  357.      The storage for the _I_M_P_I_m_a_g_e structure is allocated by the image open
  358.      function. This storage is deallocated by the _i_m_p_C_l_o_s_e and _i_m_p_C_l_o_s_e_F_d
  359.      functions.  The caller should not explicitly reallocate or deallocate any
  360.      storage related to the image structure.
  361.  
  362. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  363.      libimp(3), impReadRow(3), impReadRowB(3), mmap(2)
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.